<?php
/**
 * Created by PhpStorm.
 * User: ylq
 * Date: 2018/7/11
 * Time: 11:25
 */

namespace doc\analysis;

use Yii;
class web
{
    function loadModel($app_name, $data = array())
    {
        $route = Yii::$app->controller->route;
        list($class, $action) = explode('/', $route);

        $container = new Yii\di\Container;
        $container->set('model', $app_name . "\\models\\{$class}Model");
        $model = $container->get('model');
        $data = call_user_func_array(array($model, "action{$action}"), array('a' => $data));
        $data = $data ? $data : array();
        return $data;
    }
}